const { 
    getType,
    updateType,
    createType,
    destroyType
} = require('../service/type'),
     { updateToQIniu,API, returnInfo } = require('../lib/utils'),
     { nanoid } = require('nanoid'),
     { IMAGE_UPLOAD,API } = require('../config/config'),
     { qiniu } = require('../config/config'),
     path = require('path');
class Type{
    async getTypeC(ctx){
        try {
            const { id } = ctx.request.body;
            let returnMess = await getType(id);
            ctx.body = returnInfo(APT.GET_TYPE_SUCCESS,returnMess);
        } catch (error) {
            console.log(error);
            ctx.body = returnInfo(API.GET_TYPE_ERROR);
        }
    }
    async createTypeC(ctx){
        const files = ctx.request.files,
              data = ctx.request.body,
              typeimg = '';
        if(files){
            let extname = path.extname(files.name),
                filePath = files.path,
                fileName = `typephoto${nanoid()}${extname}`;
                updateToQIniu(filePath,fileName);
                typeimg = 
        }else{
            ctx.body = returnInfo()
        }      
        try {
           

        } catch (error) {
            
        }
    }
}     
module.exports = new Type();